﻿#pragma once


// GlobalVariables

class GlobalVariables : public CWnd
{
	DECLARE_DYNAMIC(GlobalVariables)

public:
	GlobalVariables();
	virtual ~GlobalVariables();

protected:
	DECLARE_MESSAGE_MAP()
};

struct AddressPLC
{
	int TotalCount;  //单卷切片总数
	int	NGCount;     //切片NG数
	int	OKCount;     //切片OK数
	int OKBoxDequeueFlagAddr;//OK弹夹出队标志位


	int	MisMatch;    //定位不齐

	//设备过程参数
	int FilmThickness; //片厚度0
	int	CutterLife;   //切刀寿命0
	int MouldLife;    //模具寿命0
	int UnreelingSpeedRadio;//放卷速比0
	int DrawPullRatio; //放牵速比0


	int SetBoxQuanlity;//料盒设定数量1
	int FilmMouldCutSetLength;//极片模切设置长度1
	int MouldCutSpeed;//模切速度1
	int LengthOffsetAddr;//长度补偿1
	
	int AlarmCodeAddr;//报警代码地址
	int AlarmCodeFlagAddr;//报警标志位地址
	int CommandDownloadAddr;//指令下发地址
	int DownloadParamModifyAddr;//是否修改下发参数
	int DeviceStatusAddr; //设备状态地址
	int DeviceStatusReasonAddr;
	int BatchAddr;
	int ClipChange;             //NG换弹夹标志位
	int ClipChange1;             //OK换弹夹标志位
	int DanJiaAdd;               //弹夹地址
	int CaiQieNum; //裁切次数
	int	MoQieNum;   //模切次数
	int	MoQieSpeedSet;  //模切速度设定 
	int	MoQieSpeedRun ; //模切速度运行
	int	FengSu1;      //激光管道风速仪信号1
	int	FengSu2;     //激光管道风速仪信号2
	int	JiaQiangJiYaLi ; //加强筋压力
	int	FangJuanJuanJing;  //放卷卷径
	int	BaiBiZhangLiRun;  //非极耳侧切割功率s
	int	BaiBiZhangLiSet;  //极耳侧切割功率s
	int	FangJuanZhangLiRun;  //放卷张力(运行)
	int	FangJuanZhangLiSet;  //放卷张力(设定)
	int	SizeLength;
	int	XiaCiLength;
	int	SizeAdd;
	int	XiaCiAdd1;
	int	XiaCiAdd2;
	int FEIJIERMIN;
	int FEIJIERMAX;
	int FEIJIERTIME;
	int JIERMIN;
	int JIERMAX;
	int JIERTIME;

	int EquStop;  //设备停止
};
struct PLCData
{
	int	NGCount;     //切片NG数
	int	OKCount;     //切片OK数

	int	MisMatch;    //定位不齐

	int FilmThickness;  //厚度
	int	CreateTime;   //创建时间
	int	CutterLife;   //切刀寿命
	int MouldLife;    //模具寿命
	int UnreelingSpeedRadio;//放卷速比
	int DrawPullRatio; //放牵速比
	int SendSetBoxQuanlity;//料盒设定数量
	int SendFilmMouldCutSetLength;//极片模切设置长度
	int SendMouldCutSpeed;//模切速度
	CString cstrBatchAddr;  //卷号
	CString cstrDanJiaAdd;  //弹夹号
	int SetBoxQuanlity;//料盒设定数量
	int FilmMouldCutSetLength;//极片模切设置长度
	int MouldCutSpeed;//模切速度
	int LengthOffset;//长度补偿
	std::vector<int> vec_AlarmCode;
	std::vector<int> vec_Size;
	std::vector<int> vec_XiaCiQian;
	std::vector<int> vec_XiaCiHou;
	int nScanCode;
	int nScanCode1;
	int nDevieStatus;
	int nDeviceStatusReason;
	int nAlarmCodeAddr;//报警代码地址

	int nCaiQieNum; //裁切次数(当班)
	int	nMoQieNum;   //模切次数(累计)
	float	fMoQieSpeedSet;  //模切速度设定 
	float	fMoQieSpeedRun; //模切速度运行
	float	fFengSu1;      //激光管道风速仪信号1
	float	fFengSu2;     //激光管道风速仪信号2
	float	fJiaQiangJiYaLi; //加强筋压力
	float	fFangJuanJuanJing;  //放卷卷径
	float	fBaiBiZhangLiRun;  //摆譬张力(运行)
	float	fBaiBiZhangLiSet;  //摆臀张力(设定)
	float	fFangJuanZhangLiRun;  //放卷张力(运行)
	float	fFangJuanZhangLiSet;  //放卷张力(设定)

	std::vector<double> vec_JiErGongLv;
	std::vector<double> vec_FeiJiErGongLv;
	double fFEIJIERMIN;
	double fFEIJIERMAX;
	double cstrFEIJIERTIME;

	double fJIERMIN;
	double fJIERMAX;
	double cstrJIERTIME;

	int nPort;

	int WorkNum;  //工位个数
};


enum DownLoadParam
{
	DownLoadParam_MouldCutSpeed,//模切速度
	DownLoadParam_SetBoxQuanlity,//料盒设定数量
	DownLoadParam_FilmMouldCutSetLength,////极片模切设置长度
	DownLoadParam_LenghtOffset//长度补偿
};

enum  DeviceProcessParam
{
   enum_MouldLife,         //模具寿命
   enum_CutterLife,        //切刀寿命
   enum_UnreelingSpeedRadio,  //放卷速比
   enum_DrawPullRatio,     //放牵速比
   enum_FilmThickness,    //片厚度
   enum_SetBoxQuanlity,      //料盒设定数量
   enum_FilmMouldCutSetLength,   //极片模切设置长度
   enum_MouldCutSpeed      //模切速度
};


struct MateFeedingInfo
{
	CString mateType; //物料类型
	CString mateTypeDesc; //物料类型描述
	CString mateNo; // 物料类型
	CString mateDesc; //物料描述
	CString mateLot;  //物料类型
	CString slot; //物料安装位置

	MateFeedingInfo()
	{
		mateType = "";
		mateTypeDesc = "";
		mateNo = "";
		mateDesc = "";
		mateLot = "";
		slot = "";
	}
};

struct MateUnloadInfo
{
	CString mateType; //物料类型
	CString mateNo; // 物料类型
	CString mateLot;  //物料类型
	CString slot; //物料安装位置
	MateUnloadInfo()
	{
		mateType = "";
		mateNo = "";
		mateLot = "";
		slot = "";
	}
};

struct InfoMES
{
	CString IP;
	int Port;
	double dTimeOut;
	int bServer;
	CString  factoryNo;  //协议编号
	CString  machineNo;  //上位机编码
	CString  EquimentNo;  //设备编码
	CString  MesUserName;  //登录张号
	CString  MesUserPassWord;  //登录张号
	BOOL  bSuccess;//Mes账户登录成功
	int nProdectType;   //生产类型
	BOOL  bEquStop;
	CString cstrReturnMsg;
	CString  EventUser;

	int     nTimeJianGe;
	int     nHeartBeatSpanTime;
	int     nHeartBeatStatusFlag;
	BOOL    bShiledHeartBeat;

	CString  strReturnMsg;
	CString  cstrBatch;

	//显示上料信息或下料信息
	BOOL bShowMateFeedingOrUnloadInfoFlag;//0：无，1：上料，2下料

	//上料信息
	MateFeedingInfo  _MateFeedingInfo;


	//下料信息
	MateUnloadInfo _MateUnloadInfo;
	BOOL  MateUnloadInfoFlag;

	//下发指令
	BOOL CommandCodeFlag;//1：接收到MES下发，2：手动解除
	int CommandCode;


	//参数下发标志位
	BOOL ParamDownloadFlag;

	double COATWIDTH;
	double COATLENGTH;
	double FOILWIDTH;
	double DISTANCE;
	double FOILHIGHT;
	double AT9;
};



struct Land
{
	CString Use1;
	CString PassWord1;
	CString Use2;
	CString PassWord2;
	CString Use3;
	CString PassWord3;
	int PassLevel;
};
extern CString g_FilePathPLC;
extern CString g_FilePathLog;
extern CString g_SystemPathPLC;
extern CString g_MESPathLog;
extern AddressPLC g_PLCAddress;
extern DHInterface* g_pPlc;//Plc通信模块
extern InfoMES g_InfoMes;  //MES信息
extern Land g_Land; //账号密码信息
extern PLCData g_PLCData;  //发送数据
extern PVOID     g_pMainDialog;       //主对话框;

extern  BOOL  g_bUseMes;
extern  BOOL  g_bUsePlc;


extern CResultOperation g_SendData;
extern HTuple  g_hvHeartBeatStartTime;
extern HTuple  g_hvHeartBeatEndTime;
extern CString g_cstrFilePath;
extern CString g_cstrErrorFilePath;
extern DHInterface* g_pWatch;//异常模块

extern int g_nType;//类型
extern int g_nNGLENGTH;//NG地址长度
extern std::vector<MateFeedingInfo> vec_FeedMes;
extern int g_nWorkFlag;
extern CRITICAL_SECTION m_csChange;
extern int g_nConnectStatus;
extern int g_nMsgNo;
extern HTuple  g_hvMes1;
extern HTuple  g_hvMes2;
extern HTuple  g_hvMes3;
extern HTuple  g_hvMes4;
extern HTuple  g_hvMes5;
extern CString g_cstrOKDanJiaStartTime;
extern CString g_cstrNGDanJiaStartTime;
extern CString g_cstrSendDanJiaStartTime;